/*
 * Created on 17-feb-2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package it.unibo.deis.lia.filters.graphic;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import java.util.*;

/**
 * @author Carlo Giannelli
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class FunctionFrame
	extends JFrame
	implements ComponentListener, FocusListener, WindowFocusListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	TreeMap db;
	int min, max;
	
	public FunctionFrame(String titolo,TreeMap db,int min,int max) throws HeadlessException {
		super(titolo);
		this.addComponentListener(this);
		this.addFocusListener(this);
		this.db=db;
		this.min=min;
		this.max=max;
	}
	
	public FunctionFrame(TreeMap db,int min,int max) throws HeadlessException {
		this.addComponentListener(this);
		this.addFocusListener(this);
		this.db=db;
		this.min=min;
		this.max=max;
	}
	
	public void draw(){
		java.awt.Insets i=this.getInsets();
		FunctionPanel p=new FunctionPanel(db,(int)Math.round(this.getWidth())-i.left-i.right-1,(int)Math.round(this.getHeight())-i.top-i.bottom-1,min,max);
		this.getContentPane().add(p);
		this.validate();
	}
	
	public void componentHidden(ComponentEvent e) {
		draw();
	}

	public void componentMoved(ComponentEvent e) {
		draw();
	}

	public void componentResized(ComponentEvent e) {
		draw();
	}

	public void componentShown(ComponentEvent e) {
		draw();
	}

	public void focusGained(FocusEvent e) {
		draw();
	}

	public void focusLost(FocusEvent e) {
		draw();
	}
	
	public void windowGainedFocus(WindowEvent e) {
		draw();
	}
	
	public void windowLostFocus(WindowEvent e) {
		draw();
	}

}
